package com.hefeng.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.hefeng.domain.WxAboutus;
import com.hefeng.service.IWxAboutusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hefeng.common.log.annotation.Log;
import com.hefeng.common.log.enums.BusinessType;
import com.hefeng.common.security.annotation.RequiresPermissions;

import com.hefeng.common.core.web.controller.BaseController;
import com.hefeng.common.core.web.domain.AjaxResult;
import com.hefeng.common.core.utils.poi.ExcelUtil;
import com.hefeng.common.core.web.page.TableDataInfo;

/**
 * 关于我们信息Controller
 * 
 * @author ruoyi
 * @date 2022-09-06
 */
@RestController
@RequestMapping("/aboutus")
public class WxAboutusController extends BaseController
{
    @Autowired
    private IWxAboutusService wxAboutusService;

    /**
     * 查询关于我们信息列表
     */
    @RequiresPermissions("system:aboutus:list")
    @PostMapping("/list")
    public TableDataInfo list(WxAboutus wxAboutus)
    {
        startPage();
        List<WxAboutus> list = wxAboutusService.selectWxAboutusList(wxAboutus);
        return getDataTable(list);
    }

    /**
     * 导出关于我们信息列表
     */
    @RequiresPermissions("system:aboutus:export")
    @Log(title = "关于我们信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WxAboutus wxAboutus)
    {
        List<WxAboutus> list = wxAboutusService.selectWxAboutusList(wxAboutus);
        ExcelUtil<WxAboutus> util = new ExcelUtil<WxAboutus>(WxAboutus.class);
        util.exportExcel(response, list, "关于我们信息数据");
    }

    /**
     * 获取关于我们信息详细信息
     */
    @RequiresPermissions("system:aboutus:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(wxAboutusService.selectWxAboutusById(id));
    }

    /**
     * 新增关于我们信息
     */
    @RequiresPermissions("system:aboutus:add")
    @Log(title = "关于我们信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WxAboutus wxAboutus)
    {
        return toAjax(wxAboutusService.insertWxAboutus(wxAboutus));
    }

    /**
     * 修改关于我们信息
     */
    @RequiresPermissions("system:aboutus:edit")
    @Log(title = "关于我们信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WxAboutus wxAboutus)
    {
        return toAjax(wxAboutusService.updateWxAboutus(wxAboutus));
    }

    /**
     * 删除关于我们信息
     */
    @RequiresPermissions("system:aboutus:remove")
    @Log(title = "关于我们信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(wxAboutusService.deleteWxAboutusByIds(ids));
    }
}
